#Makefile SPU GERO
CC=/usr/bin/ccache /usr/bin/spu-gcc
CFLAGS=-W -Wall -Winline -Wno-main
LDFLAGS=-I. -I /usr/spu/include -I /opt/cell/sdk/usr/spu/include
SRC1=fmaf4_spu.c 
SRC2=hello1_spu.c
OBJ1= $(SRC1:.c=.o)
OBJ2= $(SRC2:.c=.o)
LIB1=fmaf4_spu.a
LIB2=hello1_spu.a
EXEC1=fmaf4_spu
EXEC2=hello1_spu

#makefile normal
%o: %c
	$(CC) $(CFLAGS) $(LDFLAGS) -O3 -c $< -lsimdmath

exec: $(OBJ1) $(OBJ2)
	$(CC) -o $(EXEC1) $(OBJ1) -Wl,-N -lsimdmath
	$(CC) -o $(EXEC2) $(OBJ2) -Wl,-N -lsimdmath                              
exec_embed: exec
	/usr/bin/ppu-embedspu -m32 $(EXEC1) fmaf4_spu $(EXEC1)-embed32.o
	/usr/bin/ppu-embedspu -m32 $(EXEC2) hello1_spu $(EXEC2)-embed32.o          
gen: $(SRC)
	@../../gero/c18 *_spu.c

lib:exec_embed
	/usr/bin/ppu-ar -qcs $(LIB1) $(EXEC1)-embed32.o
	/usr/bin/ppu-ar -qcs $(LIB2) $(EXEC2)-embed32.o                          
clean:   
	rm -rf *.o *.a $(EXEC1)  $(EXEC2) *~ gen_spu.*
